<taglib name='Html' />
<div class="Item hr">
    <div class="fr"><a href="{:U('index')}" class="btn">栏目管理</a></div>
    <div class="current">批量添加栏目</div>
</div>
<form>
      <input type="hidden" name="savetype" value="" id="savetype"/>
    <div class="Item hr">
        <div class="current">公用参数</div>
    </div>
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="table1">
    	<tr>
            <th>目录保存位置：</th>
            <td><label><input name="referpath" type="radio" id="truepath1" class="np" value="parent" checked='1' />
              默认HMTL目录(
                <php>
                    $pardir = '{cmspath}'.C('HTML_DIR');
                    if(!empty($typedir)) $pardir = $typedir.'/';
                    $pardir = preg_replace("#\/{1,}#", '/', $pardir);
                    echo $pardir;
                </php>) </label> 
              <label><input name="referpath" type="radio" id="truepath2" class="np" value="cmspath" />
              CMS根目录</label> 
              <input name="nextdir" type="hidden" id="nextdir" value="<?php echo $pardir; ?>" />
            <span id="pathtype" style="display:none"><label><input name="referpath" type="radio" id="truepath3" class="np" value="typepath" />隶属栏目所属的目录</label></span></td>
          </tr>
        <tr>
            <th width="100">内容模型：</th>
            <td>
            	<select name="public[model_id]" id="model_id">
                	<volist name='models' id='model'>
                	<option value="{$model.id}" <if condition="$model['id'] eq $model_id">selected="true"</if>>{$model.name}|{$model.nid}</option>
                    </volist>
                </select>
             </td>
        </tr>
        <present name="language">
        <tr>
            <th width="100">所属语言：</th>
            <td>
            <html:select options="language" name="public[lang]" id="lang" />
             </td>
        </tr>
        </present> 
        <tr>
            <th width="100">隶属栏目：</th>
            <td>
            	<select name="public[reid]" id="reid" onChange="showSeltype(this)">
                	<option value="0">选择所属目录... </option>
                <present name="language">
                	<volist name='types' id='m'>
                    <optgroup label="{$m.title}">
                        <volist name='m.cat' id='type'>
                            <option value="{$type.id}">{$type.fullname}</option>
                        </volist>
                    </optgroup>
                    </volist>
                <else/>
                	<volist name='types' id='type'>
                	<option value="{$type.id}">{$type.fullname}</option>
                    </volist>
                 </present> 
               </select> （默认为顶级栏目） 
             </td>
        </tr>
        <tr>
            <th>栏目列表选项：</th>
            <td>
            <input type="radio" value="-1" name="public[isdefault]" checked="checked" >
            使用动态页
            <input type="radio" value="1" name="public[isdefault]">
            链接到默认页
            <input type="radio" value="0" name="public[isdefault]">
            链接到列表第一页
            </td>
        </tr>          
        <tr>
            <th>默认页的名称： </th>
            <td>
            <input type="text" class="input" value="index.html" name="public[defaultname]">
            </td>
        </tr>        
        
        <tr>
            <th width="100">文章命名规则：</th>
            <td><input id="namerule" type="text" class="input" size="40" name="public[namerule]" value="{typedir}/{Y}/{M}{D}/{aid}.html" /> </td>
        </tr>
        <tr>
            <th width="100">列表命名规则：</th>
            <td><input id="namerule2" type="text" class="input" size="40" name="public[namerule2]" value="{typedir}/list_{tid}_{page}.html" /> </td>
        </tr>
    </table>
    <div class="Item hr">
        <div class="current">栏目填写</div>
    </div>

<table id="addQuick" width="800" border="0" cellspacing="0" cellpadding="0" class="tab">
  <tbody>
    <tr align="center">
        <td width="60" height="28">排序</td>
        <td width="170">顶级栏目名称</td>
        <td width="520">子栏目(用&quot;目录名称1,目录名称2...&quot;这样表示多个栏目)</td>
      <td width="50" align="center"><input name="" type="button" value="添加" id="add" class="coolbt btn"></td>
    </tr>
    <tr height="32"  align="center">
      <td class="rank">
        <input type="text" name="rank[]" value="1" class="input" style="width:50px;" /></td>
      <td align='center'><input type="text" name="toptype[]" class="input" style="width:160px;" /></td>
      <td><input type="text" name="sontype[]" class="input" style="width:480px;" /></td>
      <td align="center"><input name="" type="button" value="删除" id="add" class="del coolbt btn"></td>
    </tr>
    <?php for($i=2;$i<=10;$i++) { ?>
    <tr height="32" class="repeat"  align="center">
      <td class="rank">
        <input type="text" name="rank[]" value="<?php echo $i; ?>" class="input" style="width:50px;" /></td>
      <td align='center'><input type="text" name="toptype[]" class="input" style="width:160px;" /></td>
      <td><input type="text" name="sontype[]" class="input" style="width:480px;" /></td>
      <td align="center"><input name="" type="button" value="删除" id="add" class="del coolbt btn"></td>
    </tr>
    <?php } ?>
  </tbody>
</table>
<table id="addQuickRel" width="320" border="0" cellspacing="0" cellpadding="0" class="tab" style="display:none;">
  <tbody>
    <tr align="center">
      <td width="60" height="28">排序</td>
      <td width="170">栏目名称</td>
      <td width="50" align="center"><input name="" type="button" value="添加" id="addrel" class="coolbt btn"></td>
    </tr>
    <tr height="32"  align="center">
      <td class="rank" style="padding:5px;">
        <input type="text" name="relrank[]" value="1" class="input" style="width:50px;" /></td>
      <td align='center'><input type="text" name="reltype[]" class="input" style="width:160px;" /></td>
      <td align="center"><input name="" type="button" value="删除" id="add" class="del coolbt btn"></td>
    </tr>
    <?php for($i=2;$i<=10;$i++) { ?>
    <tr height="32" class="repeat"  align="center">
      <td class="rank">
        <input type="text" name="relrank[]" value="<?php echo $i; ?>" class="input" style="width:50px;" /></td>
      <td align='center'><input type="text" name="reltype[]" class="input" style="width:160px;" /></td>
      <td align="center"><input name="" type="button" value="删除" id="add" class="del coolbt btn"></td>
    </tr>
    <?php } ?>
  </tbody>
</table>
</form>
<div class="commonBtnArea" >
    <button class="btn submit">提交</button>
</div>

<script type="text/javascript">
function showSeltype(objname)
{
	if(objname.value != 0)
	{
		$("#addQuickRel").show();
		$("#pathtype").show();
		$("#addQuick").hide();
		$("#savetype").val('rel');
	} else {
		$("#addQuickRel").hide();
		$("#addQuick").show();
		$("#pathtype").hide();
		$("#savetype").val('');
	}
}

$(function(){
	$(".submit").click(function(){
		commonAjaxSubmit("{:U('savequick')}");
	});
});
</script>
<script type="text/javascript">
$(document).ready(function(){
    //删除按钮事件
    $("#addQuick .del").click(function() {
        $(this).parents(".repeat").remove();
    });
    //添加按钮事件
    $("#add").click(function(){
		var id = $("#addQuick tr").prevAll("tr").length + 1;
        $("#addQuick tr:eq(1)").clone(true).addClass("repeat")
			.find(".rank input")
                .attr("value",function(){return id})
				.end()
            .find(".pubinputs")
                .attr("name",function(){return this.name+id})
				.attr("id",function(){return this.id+id})
                .end()
            .appendTo($("#addQuick"));
    });
    //删除按钮事件
    $("#addQuickRel .del").click(function() {
        $(this).parents(".repeat").remove();
    });
    //添加按钮事件
    $("#addrel").click(function(){
		var id = $("#addQuickRel tr").prevAll("tr").length + 1;
        $("#addQuickRel tr:eq(1)").clone(true).addClass("repeat")
			.find(".rank input")
                .attr("value",function(){return id})
				.end()
            .find(".pubinputs")
                .attr("name",function(){return this.name+id})
				.attr("id",function(){return this.id+id})
                .end()
            .appendTo($("#addQuickRel"));
    });
});
</script>
